package com.jingdianjichi.wx.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ClassName :SubscribeMsgHandler
 * Package :com.jingdianjichi.wx.handler
 * Desciption :
 *
 * @Author :
 * @Create : 23:23
 * @Version :1.0
 */
@Component
@Slf4j
public class SubscribeMsgHandler implements WxChatMsgHandler {


    @Override
    public WxChatMsgTypeEnum getMsgType() {
        return WxChatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String, String> messageMap) {

        log.info("触发用户注册事件");
        String FromUserName = messageMap.get("FromUserName");
        String ToUserName = messageMap.get("ToUserName");
        String subscribeContent = "感谢你的关注";
        String content = "<xml>\n" +
                "  <ToUserName><![CDATA[" + FromUserName + "]]></ToUserName>\n" +
                "  <FromUserName><![CDATA[" + ToUserName + "]]></FromUserName>\n" +
                "  <CreateTime>12345678</CreateTime>\n" +
                "  <MsgType><![CDATA[text]]></MsgType>\n" +
                "  <Content><![CDATA[" + subscribeContent + "]]></Content>\n" +
                "</xml>";
        return content;
    }
}
